function inheritPrototype(SubType, SuperType) {
  SubType.prototype = Object.create(SuperType.prototype)
  Object.defineProperty(SubType.prototype, 'constructor', {
    value: SubType,
    configurable: true,
    enumerable: false,
    writable: true
  })
}

function Person(name, age) {
  this.name = name
  this.age = age
}

Person.prototype.eating = function () {
  console.log(this.name + 'eating')
}


function Student(name, age, sno) {
  Person.call(this, name, age)
  this.sno = sno
}

//加一层中间层,让Student继承自Person
inheritPrototype(Student, Person)

Student.prototype.studying = function () {
  console.log(this.name + 'studying')
}

var stu = new Student('lijing', 18, 1001)
stu.eating()
console.log(stu)
console.log(Student.prototype.__proto__)
console.log(Person.prototype === Student.prototype.__proto__)
